#include"myredis.h"
namespace myredis
{
bool Myredis::connect(string ip,int port)
{
this->_connect=redisConnect(ip.c_str(),port);
if(this->_connect!=nullptr&&this->_connect->err)
{
    perror("myredis connect");
    return false;
}
return true;
}
string Myredis::read(string key)
{
this->_redis_return=(redisReply*)redisCommand(this->_connect,"get %s",key.c_str());
string str=this->_redis_return->str;
freeReplyObject(this->_redis_return);
this->_redis_return=nullptr;
return str;
}
void Myredis::write(string key,string value)
{
this->_redis_return=(redisReply*)redisCommand(this->_connect,"set %s %s",key.c_str(),value.c_str());
freeReplyObject(this->_redis_return);
this->_redis_return=nullptr;
}
}